/*
package com.lysj.bhp.wallet.job;


import com.lysj.bhp.wallet.base.CoinContent;
import com.lysj.bhp.wallet.domain.BhpcWallet;
import com.lysj.bhp.wallet.util.EtherScanUtil;
import com.lysj.bhp.recharge.domain.RechargeRecord;
import com.lysj.bhp.user.domain.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class BhpcJob extends CoinContent {

    private static Logger logger = LoggerFactory.getLogger(BhpcJob.class);


    */
/*第一次10秒后执行，当执行完后0.2秒再执行，保证一秒并发不超过5个*//*

    @Scheduled(initialDelay = 10000, fixedDelay = 500)
    public void queryEthereumWallet() {
        logger.info("BhpcJob is Starting ...");
        BhpcWallet bhpcWallet = bhpcWalletRepository.findFirstByOrderByLastQueryTimeAsc();
        if (bhpcWallet == null) {
            return;
        }
        double realBhpcBalance = EtherScanUtil.getBalanceTokenBHPC("0x" + bhpcWallet.getAddress());
        if (realBhpcBalance < 0) { //
            logger.error("EherscanUtil return -1,bhpcWalletId is " + bhpcWallet.getBhpcWalletId());
            bhpcWallet.setLastQueryTime(System.currentTimeMillis());
            bhpcWalletRepository.save(bhpcWallet); // !!!即使发生错误,也应该继续执行下一次的查询!!!
            return;
        }
        if (realBhpcBalance <= bhpcWallet.getBalance()) { //查询到的余额小于钱包得真实余额，则更新
            bhpcWallet.setBalance(realBhpcBalance);
        } else {
            logger.info("BhpcWallet  Balance Increment,Start Record!" + bhpcWallet.getBhpcWalletId());
            double increase = realBhpcBalance - bhpcWallet.getBalance(); // 增加的余额
            User user = userRepository.findOne(bhpcWallet.getUserId());
            user.setBhpc(user.getBhpc() + increase);
            bhpcWallet.setBalance(realBhpcBalance);
            // 创建充值记录
            RechargeRecord rechargeRecord = new RechargeRecord();
            rechargeRecord.setCoinType(3);
            rechargeRecord.setPayAmount(increase);
            rechargeRecord.setUserId(bhpcWallet.getUserId());
            rechargeRecord.setCreateTime(new Date());
            rechargeRecordRepository.save(rechargeRecord);
            userRepository.save(user);
        }
        bhpcWallet.setLastQueryTime(System.currentTimeMillis()); // 将最近的查询时间设置为现在
        bhpcWalletRepository.save(bhpcWallet);
    }


}
*/
